package com.example.demo.util.codeGen;

//import com.gm.wj.util.StringUtils;
import com.example.demo.util.StringUtils;
import lombok.*;

import java.util.HashMap;
import java.util.Map;

@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Builder
//@Entity
//@Table
//PlanTimeSlotRepository
//ColumnInfoRepository
public class ColumnInfo {
     String TABLE_CATALOG = "def";
     String IS_NULLABLE = "YES";
     String TABLE_NAME = "notice";
     String TABLE_SCHEMA = "gcsm";
     String EXTRA = "";
     String COLUMN_NAME = "state";
     String COLUMN_KEY = "";
     String COLUMN_COMMENT = "公告状态";
     String PRIVILEGES = "select,insert,update,references";
     String COLLATION_NAME = "utf8_general_ci";
     String COLUMN_TYPE = "varchar(255)";
     String DATA_TYPE = "varchar";
     String CHARACTER_SET_NAME = "utf8";
     String java字段名;
     String java字段名开头大写;

     public String 获取java字段类型(){
//          String data_type = columnInfo.getDATA_TYPE();
//            "varchar";
          String java字段类型 = ColumnInfo.DATA_TYPE_Map.get(DATA_TYPE);
          if(java字段类型==null){
               return "String";
          }
          return java字段类型;
     }
    public  static Map<String, String> DATA_TYPE_Map=new HashMap<>();

     static {
          DATA_TYPE_Map.put("varchar","String");
          DATA_TYPE_Map.put("int","Integer");
          DATA_TYPE_Map.put("tinyint","Integer");
          DATA_TYPE_Map.put("longtext","String");
          DATA_TYPE_Map.put("datetime","Date");
          DATA_TYPE_Map.put("double","Double");
          DATA_TYPE_Map.put("char","String");
//          Integer
     }
     public static void main(String[] args) {
//          ColumnInfo columnInfo=new ColumnInfo();
//          columnInfo.getCHARACTER_SET_NAME()
     }

//     public  void fromMap(Map<String ,Object>map){
//          TABLE_CATALOG= (String) map.get("");
//     }

     public  void fromMap(Map<String, Object> map){
          TABLE_CATALOG = (String)map.get("TABLE_CATALOG");
          IS_NULLABLE = (String)map.get("IS_NULLABLE");
          TABLE_NAME = (String)map.get("TABLE_NAME");
          TABLE_SCHEMA = (String)map.get("TABLE_SCHEMA");
          EXTRA = (String)map.get("EXTRA");
          COLUMN_NAME = (String)map.get("COLUMN_NAME");
          COLUMN_KEY = (String)map.get("COLUMN_KEY");
          COLUMN_COMMENT = (String)map.get("COLUMN_COMMENT");
          PRIVILEGES = (String)map.get("PRIVILEGES");
          COLLATION_NAME = (String)map.get("COLLATION_NAME");
          COLUMN_TYPE = (String)map.get("COLUMN_TYPE");
          DATA_TYPE = (String)map.get("DATA_TYPE");
          CHARACTER_SET_NAME = (String)map.get("CHARACTER_SET_NAME");
          java字段名= StringUtils.underlineToCamelCase(COLUMN_NAME);
          java字段名开头大写= StringUtils.upperCaseFirst(java字段名);
     }


}
